<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript">
        window.onload = function () {

            /**
            * BOM (Browser Object Model): 浏览器对象模型
            * 1. window对象 : 浏览器窗口
            * 2. location对象 : 浏览器地址栏信息
            * 3. history对象 : 浏览器历史记录
            * 4. navigator对象 : 浏览器信息
            * 5. screen对象 :  屏幕信息
            * 6. document对象 : 文档对象
            */
            //Navigator对象
            //由于历史原因，navigator对象的属性是不规范的，不同浏览器可能会有不同的属性
            console.log("--------navigator--------"); //浏览器名称
            console.log("navigator.appName=" + navigator.appName); //浏览器版本
            console.log("navigator.appCodeName=" + navigator.appCodeName); //浏览器版本Code
            console.log("navigator.appVersion=" + navigator.appVersion); //浏览器厂商
            console.log("navigator.vendor=" + navigator.vendor); //浏览器引擎 
            console.log("navigator.platform=" + navigator.platform); //操作系统   
            console.log("navigator.language=" + navigator.language); //浏览器语言 
            console.log("navigator.onLine=" + navigator.onLine); //是否在线   
            console.log("navigator.cookieEnabled=" + navigator.cookieEnabled); //是否支持cookie
            console.log("navigator.userAgent=" + navigator.userAgent); //用户代理字符串
            console.log("navigator.product=" + navigator.product); //产品名
            if (window.ActiveXObject) {
                console.log("IE浏览器");
            }
            if ("ActiveXObject" in window) {
                console.log("IE浏览器");
            }
            //Location对象
            console.log("--------location--------");
            console.log("location.href=" + location.href); //当前页面的URL
            console.log("location.protocol=" + location.protocol); //协议
            console.log("location.host=" + location.host); //主机名
            console.log("location.hostname=" + location.hostname); //主机名
            console.log("location.port=" + location.port); //端口
            console.log("location.pathname=" + location.pathname); //路径
            console.log("location.search=" + location.search); //查询字符串
            console.log("location.hash=" + location.hash); //锚点 
            console.log("location.origin=" + location.origin); //协议+主机名+端口 
            //console.log("location.assign()="+location.assign("https://www.baidu.com")); //跳转
            //console.log("location.replace()="+location.replace("https://www.baidu.com")); //替换
            //console.log("location.reload()="+location.reload()); //刷新 
            console.log("location.toString()=" + location.toString()); //转字符串 
            //History对象
            console.log("--------history--------");
            console.log("history.length=" + history.length); //历史记录的数量
            console.log("history.state=" + history.state); //当前页面的状态
            console.log("history.scrollRestoration=" + history.scrollRestoration); //滚动条恢复方式
            //console.log("history.back()="+history.back()); //后退
            //console.log("history.forward()="+history.forward()); //前进
            //console.log("history.go(-1)="+history.go(-1)); //后退
            //Window对象
            console.log("--------window--------");
            let h1 = document.getElementById("h1");
            //定时器
            let timer = window.setInterval(function () {
                console.log(h1.innerHTML);
                h1.innerHTML = parseInt(h1.innerHTML) + 1;
                if (parseInt(h1.innerHTML) == 10) {
                    window.clearInterval(timer);
                }
            }, 1000);

            //延时执行
            console.log("window.setTimeout()="+window.setTimeout(function(){console.log("setTimeout")},1000)); //延时执行


        }

    </script>
</head>

<body>
    <a href="https://www.baidu.com">百度</a>
    <h1 id="h1">1</h1>
</body>

</html>